package com.bothin.experiment4.service.impl;

import com.bothin.experiment4.model.Customer;
import com.bothin.experiment4.service.ICustomerService;
import com.bothin.experiment4.service.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by bothin
 * At 2019/12/17 0:40
 * Description:
 */
@Service
public class CustomerServiceImpl extends BaseServiceImpl<Customer> implements ICustomerService {
    @Override
    public Customer findById(Object id) {
        return customerMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Customer> findAll() {
        return customerMapper.selectAll();
    }

    @Override
    @Transactional
    public void deleteById(Object id) {
        customerMapper.deleteByPrimaryKey(id);
    }

    @Override
    @Transactional
    public void update(Customer customer) {
        customerMapper.updateByPrimaryKeySelective(customer);
    }

    @Override
    @Transactional
    public void insert(Customer customer) {
        customerMapper.insertSelective(customer);
    }

    @Override
    public List<Customer> findByKeyword(String key) {
        return customerMapper.findByKeyword("%"+key+"%");
    }
}
